package mytest.wd3;

import java.util.UUID;

public class Test_12 {
    public static void main(String[] args) {
        String DIAL_TASK_REGISTER_SQL = "SELECT\n" +
                "    t.task_id,\n" +
                "    t.create_time,\n" +
                "    t.update_time,\n" +
                "    t.cus_id,\n" +
                "    t.phone,\n" +
                "    t.state,\n" +
                "    t.dial_status,\n" +
                "    t.status_update_time,\n" +
                "    t.achieve_time,\n" +
                "    t.loan_num,\n" +
                "    t.loan_amount\n" +
                "FROM\n" +
                "    t_business_achieve_data bad\n" +
                "INNER JOIN\n" +
                "(\n" +
                "    SELECT\n" +
                "        a.* \n" +
                "    FROM\n" +
                "        t_dial_task_%s a\n" +
                "    LEFT JOIN t_cus_cat_achieve b ON a.cus_cat = b.cus_cat \n" +
                "        AND a.business_id = b.business_id \n" +
                "        AND a.user_classify = b.user_classify \n" +
                "    WHERE\n" +
                "        b.achieve = %s \n" +
                "    UNION ALL\n" +
                "    SELECT\n" +
                "        a.* \n" +
                "    FROM\n" +
                "        t_dial_task_%s a\n" +
                "    LEFT JOIN t_cus_cat_achieve b ON a.cus_cat = b.cus_cat \n" +
                "        AND a.business_id = b.business_id \n" +
                "        AND a.user_classify = b.user_classify \n" +
                "    WHERE\n" +
                "        b.achieve = %s\n" +
                "    UNION ALL\n" +
                "    SELECT\n" +
                "        a.* \n" +
                "    FROM\n" +
                "        t_dial_task_%s a\n" +
                "    LEFT JOIN t_cus_cat_achieve b ON a.cus_cat = b.cus_cat \n" +
                "        AND a.business_id = b.business_id \n" +
                "        AND a.user_classify = b.user_classify \n" +
                "    WHERE\n" +
                "        b.achieve = %s \n" +
                ") t\n" +
                "ON bad.user_id = t.cus_id\n" +
                "AND bad.hash_phone = t.phone";

        System.out.println(DIAL_TASK_REGISTER_SQL);
    }
}
